package com.yjhb.android.sbz.mvp.newcomer;

import com.yjhb.android.sbz.entity.NewcomerState;
import com.yjhb.android.sbz.entity.UserBehavior;
import com.yjhb.android.sbz.http.HttpObserver;
import com.yjhb.android.sbz.http.HttpTool;
import com.yjhb.android.sbz.mvp.ConventionPresenter;

/**
 * 创建者 zx
 * 创建时间 2020/12/29 9:56
 */
public class NewcomerWelfarePresenter extends ConventionPresenter<NewcomerWelfareView> {
    private final String TAG = "NewcomerWelfarePresenter";

    public NewcomerWelfarePresenter(NewcomerWelfareView newcomerWelfareView) {
        super(newcomerWelfareView);
    }

    @Override
    protected void onDestroy() {

    }

    public void getNewcomerState() {
        if (view != null) {
            view.onWait("正在获取");
        }
        HttpTool.request(model.getNewUserGiftStatus(), new HttpObserver<NewcomerState>() {
            @Override
            public void onResult(NewcomerState data) {
                if (view != null) {
                    view.onState(data);
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });
    }

    /**
     * 1、完成新手指南；2、用户首次分享；3、完成3个简单任务；4、完成一次提现；5、完成简单答题；6、完成三个高价任务
     *
     * @param type
     */

    public void newUserGift(Integer type) {
        if (view != null) {
            view.onWait("正在领取");
        }
        HttpTool.request(model.newUserGift(type), new HttpObserver<Object>() {

            @Override
            public void onResult(Object data) {
                if (view != null) {
                    view.onSubmitSuccess();
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg,type);
                }
            }
        });
    }


    /**
     * 获取任务完成数量
     */
    public void getUserBehavior() {
        HttpTool.request(model.getTotalTaskBehavior(), new HttpObserver<UserBehavior>() {
            @Override
            public void onResult(UserBehavior data) {
                if (view != null) {
                    view.UserBehavior(data);
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });
    }
}
